<?php
class Controller_App_Message extends Controller_App_Template
{
    public function __construct ($req, $res)
    {
        $this->template = "smarty:app/service/blank";
        parent::__construct($req, $res);
    }

    public function action_index ()
    {
        $this->action_list();
    }

    // 展示消息列表
    public function action_list()
    {
        $uid = $this->_uid;
        list($count_total,  $count_unread,  $list) = App_Usermessage::get_list($uid);

        $this->template->set('count_total',  $count_total);
        $this->template->set('count_unread',  $count_unread);
        $this->template->set('list',  $list);
        $this->template->set_filename('smarty:app/test/messagelist');
    }
    
    // 展示消息详情
    public function action_content($id)
    {
        $info = App_userMessage::get_content($id);
        App_userMessage::set_status($id);
        $this->template->set('info',  $info);
        $this->template->set_filename('smarty:app/test/messagecontent');
    }
    
    // 添加消息接口
    public function action_add( $message ,$type)
    {
        $uid = $this->_uid;
        $result = App_userMessage::add_message($uid, $message ,$type);
        return json_encode($result);
    }

}
